//
//  BCBaseViewController.m
//  BananaChat
//
//  Created by 于洪东 on 2019/11/1.
//  Copyright © 2019 香蕉. All rights reserved.
//

#import "BCBaseViewController.h"

@interface BCBaseViewController ()

// 返回按钮
@property (nonatomic,strong) UIButton *backButton;

@end

@implementation BCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 防止子类重写，这里不要用setupUI
    [self setupBaseUI];
}

-(void)dealloc{
    
    DEF_DEBUG(@"%@释放了",self);
}


#pragma mark - ♻️life cycle

#pragma mark - 🔄overwrite

#pragma mark - 🚪public
-(void)hideBackButton{
    self.backButton.hidden = YES;
}

-(void)hideNavigationBar{
    [self.navigationController setNavigationBarHidden:YES];
}

-(void)showNavigationBar{
    [self.navigationController setNavigationBarHidden:NO];
}

#pragma mark - 🍐delegate

#pragma mark - ☎️notification

#pragma mark - 🎬event response
-(void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 🔒private

#pragma mark - 🌲setupUI

-(void)setupBaseUI{
        
    self.view.backgroundColor = NTBackGroundColor;
    
    
    self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.backButton.frame = CGRectMake(0, 0*ScaleX, 44*ScaleX, 44*ScaleX);
    [self.backButton setImage:[UIImage imageNamed:@"coin_back_black"] forState:UIControlStateNormal];
    [self.backButton setImage:[UIImage imageNamed:@"coin_back_black"] forState:UIControlStateSelected];
    [self.backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
    [self.backButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithCustomView:self.backButton];
    self.navigationItem.leftBarButtonItem = backItem;
    
}

#pragma mark - ☸getter and setter

@end
